//
//  DetailWebViewController.m
//  ioshuanwu
//
//  Created by 殷殷明静 on 16/9/20.
//  Copyright © 2016年 幻音. All rights reserved.
//

#import "DetailWebViewController.h"
#import "YMJMacro_h.h"
@interface DetailWebViewController ()<UIWebViewDelegate>
@property (nonatomic, strong) UIButton *backBtn;
@property (nonatomic, strong) NSMutableArray *imageArr;
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UIWebView *web;
@end

@implementation DetailWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.edgesForExtendedLayout = 0;
    [self initNavigationLeftButton];
    _web = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT )];
    _web.backgroundColor = [UIColor clearColor];
    [_web loadRequest:[NSMutableURLRequest requestWithURL:[NSURL URLWithString:_shareLink]]];
    [self.view addSubview:_web];
    _web.delegate = self;
    _imageArr = [NSMutableArray array];
    for (int i = 0; i < 7; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"walk%d",i]];
        [_imageArr addObject:image];
    }
    _imageView = [[UIImageView alloc] init];
    _imageView.frame = CGRectMake(0, 0, 30,38);
    _imageView.center = CGPointMake(SCREEN_WIDTH / 2, (SCREEN_HEIGHT - 64) / 2);
    [self.view addSubview:_imageView];
    _imageView.animationImages = _imageArr;
    _imageView.animationDuration = _imageArr.count / 12;
    _imageView.animationRepeatCount = CGFLOAT_MAX;
    [_imageView startAnimating];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [_imageView stopAnimating];
    
}
- (void)initNavigationLeftButton {
    _backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:_backBtn];
    _backBtn.frame = CGRectMake(20, 20, 15, 15);
    [_backBtn setBackgroundImage:[UIImage imageNamed:@"Icon_jiantou"] forState:0];
    [_backBtn addTarget:self action:@selector(backToMyViewController) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_backBtn];
}

// 返回之前页面
- (void)backToMyViewController {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
